#include<string>

class Channel
{
public:
    Channel(int wgk, int pid) : _wgk(wgk), _pid(pid)
    {
        _name = "Channel-" + std::to_string(_wgk) + "-" + std::to_string(_pid);
    }

    std::string get_name()
    {
        return _name;
    }
    int get_pid()
    {
        return _pid;
    }

    void sent_task(int task_number)
    {
        ::write(_wgk,&task_number,sizeof(task_number));
    }

    int get_wgk()
    {
        return _wgk;
    }

    void close_pipe()
    {
        close(_wgk);
        std::cout<<"关闭管道：......"<<_pid<<std::endl;
    }



private:
    // 表示文件描述符
    int _wgk;
    std::string _name;
    int _pid;
};
